#! /bin/bash
if [[ $1 == "" ]]
then
TD_DATE=`date -d '-1 day' "+%Y-%m-%d"`
else
TD_DATE=$1
fi

TD_YEAR=$(date -d "$TD_DATE" +%Y)

mysql -uroot -p123456 -h192.168.52.150 -P3306 -e "delete from scrm_bi.itcast_visit where yearinfo='$TD_YEAR';"

wait

sqoop export --connect "jdbc:mysql://192.168.52.150:3306/scrm_bi?useUnicode=true&characterEncoding=utf-8" \
--username root --password 123456 --table itcast_visit \
--hcatalog-database itcast_dws --hcatalog-table visit_dws \
--hcatalog-partition-keys yearinfo --hcatalog-partition-values $TD_YEAR \
-m 100